<template>
  <div v-show="props.compType === 'editor'">
    <el-form-item label="字段">
      <el-select v-model="props.columnName" @change="handlerChangeColumnName">
        <el-option
          v-for="item in columnNameOptions"
          :key="item.enName"
          :label="item.cnName"
          :value="item.enName">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="ID">
      <el-tooltip class="item" effect="dark" content="请注意,ID的修改可能会导致该组件相关事件失效！" placement="left">
        <el-input class="input" v-model="props.id" @change="handlerChangeId" ></el-input>
      </el-tooltip>
    </el-form-item>
    <el-divider>样式</el-divider>
    <el-form-item label="栅格">
      <el-input-number v-model="props.span"  :min="1" :max="24"/>
    </el-form-item>
    <el-form-item label="显示标签">
      <el-switch v-model="props.showLabel" @change="handlerShowLabel"></el-switch>
    </el-form-item>
    <el-form-item label="标签文字" v-show="props.showLabel">
      <el-input class="input" v-model="props.label"></el-input>
    </el-form-item>
    <el-form-item label="标签长度" v-show="props.showLabel">
      <el-input-number v-model="props.labelWidth"  :min="1" :max="200"></el-input-number>
    </el-form-item>
    <el-form-item label="必填">
      <el-switch v-model="props.required"></el-switch>
    </el-form-item>
    <el-form-item label="验证最大字数">
      <el-switch v-model="props.validateMaxText"></el-switch>
    </el-form-item>
    <el-form-item label="最大字数">
      <el-input-number v-model="props.max"  :min="100" ></el-input-number>
    </el-form-item>
    <el-divider>查询</el-divider>
    <el-form-item label="条件表达式">
      <el-select v-model="props.queryExpressType" @change="handlerChangeQueryExpressType">
        <el-option
          v-for="item in queryExpressTypeOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </el-form-item>
  </div>
</template>
<script>
import {changeId} from '../mixin'
import { getDataOptionList } from '../../../../utils/util'
export default {
  name:"editorConfig",
  // props:{
  //   props:{}
  // },
  props:['props','getFormId','columnPropertyList'],
  mixins:[changeId],
  data(){
    return {
      columnNameOptions:this.columnPropertyList,
      queryExpressTypeOptions: getDataOptionList('queryExpressTypeEnum'),
    }
  },
  methods:{
    handlerShowLabel(val){
      if(val){
        this.props.labelWidth = 80;
      }else{
        this.props.labelWidth = 0;
      }
    },
    handlerChangeColumnName(val){
      this.props.id = val;
      let option = this.columnNameOptions.find( item => item.enName == val);
      if(option){
        this.props.label = option.cnName;
        this.props.required = option.isNotNull;
        this.props.value = option.defaultValue;
        this.props.placeholder = "请输入"+option.cnName;
      }

    },
    handlerChangeFormDataFrom(value){
    },

    handlerChangeQueryExpressType(val){

    },
  }

}
</script>
